// pages/mine/index.js
var util = require('../../utils/util');
var BASE_URL = getApp().globalData.BASE_URL

Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag:true,
    name:"点击登录",
    desc:"登录更精彩",
    fans:"登录查看",
    focus:"登录查看",
    imgsrc:'https://liudediy.com/liude/images/pics_modle_46.png'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if(  util.iflogin() ){
      var userinfo=wx.getStorageSync("USER")
      console.log(userinfo)
      this.setData({
        name:userinfo.username,
        desc:userinfo.bio,
        fans:"粉丝"+"   "+userinfo.fans,
        focus:"关注"+"   "+userinfo.guanzhu,
        imgsrc:userinfo.avatar,
        flag:false
      })
    }
  },
  toLogin: function () {
    wx.navigateTo({
      url: `/views/login/index`
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  toMyhomepage: function () {
    wx.navigateTo({
      url: `/views/mine/myhomepage/index`
    })
  },
  toorder: function () {
    wx.navigateTo({
      url: `/views/mine/myorder/index`
    })
  },
  // toCollect: function () {
  //   wx.navigateTo({
  //     url: `/views/mine/mycollect/index`
  //   })
  // },
  toMessage: function () {
    wx.navigateTo({
      url: `/views/mine/mymessage/index`
    })
  },
  toMyfocus:function(){
    wx.navigateTo({
      url: `/views/mine/myfocus/index`
    })
  },
  goaboutus:function(){
    wx.navigateTo({
      url: `/views/mine/aboutus/index`
    })
  },
  gonumber:function(){
    wx.navigateTo({
      url: `/views/mine/mynumber/index`
    })
  },
  gomymoney:function(){
    wx.navigateTo({
      url: `/views/mine/mymoney/index`
    })
  }
})